package month1;

public class SymmetricTree101_05 {
    public static void main(String[] args) {
        System.out.println(isSymmetric(new TreeNode(new Integer[]{1, 2, 2, 3, 4, 4, 3})));
    }

    /**
     * 递归对比数据
     *
     * @param root
     * @return
     */
    static boolean isSymmetric(TreeNode root) {
        return isSymmetric(root, root);
    }

    static boolean isSymmetric(TreeNode t1, TreeNode t2) {
        if (t1 == null) {
            return t2 == null;
        }
        if (t2 == null) {
            return t1 == null;
        }
        return t1.val == t2.val && isSymmetric(t1.left, t2.right) && isSymmetric(t1.right, t2.left);
    }
}
